//
//  TestScene.m
//  ProjectLila
//
//  Created by Tedo on 6/26/10.
//  Copyright 2010 sushigames. All rights reserved.
//

#import "TestScene.h"
#import "MainMenuScene.h"
#import "Unit.h"
#import "PlayerUnit.h"
#import "EnemyUnit.h"

@implementation TestLayer

- (id) init {
	self = [super init];
	if (self) {
		CGSize size = [[CCDirector sharedDirector] winSize];
		
		// exit button
		[CCMenuItemFont setFontSize:24];
        [CCMenuItemFont setFontName:@"Verdana"];
        CCMenuItem *exit = [CCMenuItemFont itemFromString:@"Exit"
												   target:self
												 selector:@selector(exit:)];
        CCMenu *menu = [CCMenu menuWithItems:exit, nil];
		[menu setPosition:ccp( size.width/10, size.height/10 )];
		[self addChild:menu];
		
		// test nodes
		PlayerUnit *unit;
		for ( int i = 1; i < 2; i++ )
		{
			unit = [PlayerUnit spriteWithFile: @"ball_blue.png"];
			unit.position = ccp( size.width /2, size.height/5 *i );
			[self addChild:unit z:-unit.position.y];
		}
	}
	
	return self;
}

- (void)exit:(id)sender {
	[[CCDirector sharedDirector] replaceScene:[CCFadeTransition transitionWithDuration:0.5f scene:[MainMenuScene scene]]];
}

- (void)dealloc {
	[super dealloc];
}

@end

@implementation TestScene

+ (id) scene {
	TestScene *scene = [TestScene node];
	[scene addChild:[TestLayer node]];
	
	return scene;
}

- (void)dealloc {
	[super dealloc];
	[PlayerUnit clearAllUnits];
	[EnemyUnit clearAllUnits];
	[Unit clearAllUnits];
}

@end

